package com.pgybook.db.entity.mapper;

import org.springframework.stereotype.Repository;
import com.pgybook.db.entity.domain.BookInOrderHistory;
import com.pgybook.db.entity.domain.BookInOrderHistoryEx;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.Update;

@Repository
public interface BookInOrderHistoryMapper {
    int countByExample(BookInOrderHistoryEx example);

    int deleteByExample(BookInOrderHistoryEx example);

    @Delete({
            "delete from bookinorderhistory",
            "where BOOKINORDERHISTORYID = #{bookinorderhistoryid,jdbcType=BIGINT}"
    })
    int deleteByPrimaryKey(Long bookinorderhistoryid);

    @Insert({
            "insert into bookinorderhistory (BOOKINORDERID, INSTANCEID, ",
            "SRCSTATUS, DSTSTATUS, ",
            "CRTTIME, CRTSTAFF)",
            "values (#{bookinorderid,jdbcType=BIGINT}, #{instanceid,jdbcType=BIGINT}, ",
            "#{srcstatus,jdbcType=INTEGER}, #{dststatus,jdbcType=INTEGER}, ",
            "#{crttime,jdbcType=TIMESTAMP}, #{crtstaff,jdbcType=INTEGER})"
    })
    @SelectKey(statement = "SELECT LAST_INSERT_ID()", keyProperty = "bookinorderhistoryid", before = false, resultType = Long.class)
    int insert(BookInOrderHistory record);

    int insertSelective(BookInOrderHistory record);

    List<BookInOrderHistory> selectByExample(BookInOrderHistoryEx example);

    @Select({
            "select",
            "BOOKINORDERHISTORYID, BOOKINORDERID, INSTANCEID, SRCSTATUS, DSTSTATUS, CRTTIME, ",
            "CRTSTAFF",
            "from bookinorderhistory",
            "where BOOKINORDERHISTORYID = #{bookinorderhistoryid,jdbcType=BIGINT}"
    })
    @ResultMap("BaseResultMap")
    BookInOrderHistory selectByPrimaryKey(Long bookinorderhistoryid);

    int updateByExampleSelective(@Param("record") BookInOrderHistory record, @Param("example") BookInOrderHistoryEx example);

    int updateByExample(@Param("record") BookInOrderHistory record, @Param("example") BookInOrderHistoryEx example);

    int updateByPrimaryKeySelective(BookInOrderHistory record);

    @Update({
            "update bookinorderhistory",
            "set BOOKINORDERID = #{bookinorderid,jdbcType=BIGINT},",
            "INSTANCEID = #{instanceid,jdbcType=BIGINT},",
            "SRCSTATUS = #{srcstatus,jdbcType=INTEGER},",
            "DSTSTATUS = #{dststatus,jdbcType=INTEGER},",
            "CRTTIME = #{crttime,jdbcType=TIMESTAMP},",
            "CRTSTAFF = #{crtstaff,jdbcType=INTEGER}",
            "where BOOKINORDERHISTORYID = #{bookinorderhistoryid,jdbcType=BIGINT}"
    })
    int updateByPrimaryKey(BookInOrderHistory record);
}
